#!/usr/bin/env perl

use v5.10.1;
use strict;
use warnings;
use Encode;

$_ = "yabba dabba doo";
if(/abba/){
    say "It matched!";
}

$_ = "你好吗，哈哈哈~！";
if (/(.)\1/) { # 同bb相匹配
    say "It matched 2 !";
}


my $dat="你好吗，哈哈哈~！"; 
my $str=decode("utf8",$dat);

$_ = $str;
if (/(.)\1/) { # 同bb相匹配
    say "It matched 4 !";
}

$_ = "yabba dabba doo";
if(/y(....) d\1/){
	say "It matched 5 !";
}

my $some_other = "I dream of betty rubble.";
if ($some_other =~ /\brub/) {
	say "It matched rub !";
}

my $what = "fred|barney";
if ("fred" =~ /^($what)/) {
	say "We saw $what in to!";
}

# 变量捕获
$_ = "Hello there, neigbor";
if(/(\S+) (\S+), (\S+)/){
	say "words : $1 | $2 | $3";
}













# my @chars=split //,$str; 
# foreach my $char (@chars) { 
# 	print encode("utf8",$char),"\n"; 
# } 